/**
 * 找回密码
 * Create by RuanBanshu on 2015/2/3.
 */
FindPwdWin = Ext.extend(Ext.panel.Panel, {
    border: false,
    closable: false,
    draggable: false,
    height: 100,
    layout: 'border',
    initComponent: function () {
        var _this = this;
        Ext.apply(this, {
            items: [
                {
                    region: 'center',
                    itemId: 'form',
                    xtype: 'form',
                    layout: 'anchor',
                    border: false,
                    bodyStyle: "padding:20px;",
                    defaults: {
                        height: 32,
                        width:375,
                        padding:5
                    },
                    defaultType: 'textfield',
                    items: [
                        {
                            fieldLabel: 'Email',
                            name: 'email'
                            //,
                            //emptyText: 'Email',
                            //vtype: 'email',
                            //specialkey: function (field, e) {
                            //    if (e.getKey() == e.ENTER) {
                            //        _this.login();
                            //    }
                            //}
                        }
                        ,{
                            xtype: 'container',
                            html:'<input class="btn_x" type="button" value="发送" onclick="findPwd()">'
                        }
                    ]
                }
            ]
        });
        FindPwdWin.superclass.initComponent.call(this);
    },
    resetPwdWin:function(){
        var thisForm = this.getComponent('form').getForm();
        var emialText = thisForm.findField("email").getValue();
        var regularEmail = /\w@\w*\.\w/ ;
        if(!regularEmail.test(emialText)){
            UI.showErrorMsg('表单验证提示',
                '请输入正确的邮件地址！');
            return false;
        }
        thisForm.submit({
            clientValidation: true,
            url: F.url('/account/getPwd/retake.do'),
            success: function (form, action) {
                UI.showSuccessMsg("成功","邮件已经发送,请注意查收...");
                top.location.href = F.url("/admin/frame.do");
            },
            failure: function (form, action) {
                switch (action.failureType) {
                    case Ext.form.Action.CLIENT_INVALID:
                        UI.showErrorMsg('表单验证提示',
                            '页面表单内容验证不通过,请重新输入');
                        break;
                    case Ext.form.Action.CONNECT_FAILURE:
                        UI.showErrorMsg('网络提示', '网络连接异常，请检查网络');
                        break;
                    case Ext.form.Action.SERVER_INVALID:
                        UI.showErrorMsg("提示", action.result.msg);
                }
            }
        });
    }
});
